package com.offer;

/**
 * @Author: huangzhigao
 * @Date: 2023/3/4 15:41
 */
public class offer04 {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        int curRow = matrix.length - 1;
        int curCol = 0;
        while (curRow >= 0 && curCol < matrix[0].length) {
            if (target > matrix[curRow][curCol]) {
                //只能往左
                curCol++;
            } else if (target < matrix[curRow][curCol]) {
                curRow--;
            } else {
                return true;
            }
        }
        return false;
    }

}
